/// Creator:      gaoruishan
/// CreatDate:    2025-08-20
/// Description:  护理巡视
Class Nur.MNISV3.Service.TourRec Extends %RegisteredObject [ Not ProcedureBlock ]
{

/// 分级巡视 button的ID
/// 获取护理巡视列表
/// ***PC端 9.0版巡视查询- Nur.HISUI.MNISV4.Tour 方法 Query
///       8.5版本(兼容) Nur.HISUI.MNIS.Tour  方法 GetSumTour
/// w ##class(Nur.MNISV3.Service.TourRec).GetTourDataV4("","DHCNurGradeTourPda","2025-08-25","2025-08-25","3","20665","8","2","","{""single"":""0"",""flag"":"""",""tab"":""DHCNurGradeTourPda/"",""scan"":""0"",""multiple"":""1"",""barcode"":"""",""open"":""0""}")
/// w ##class(Nur.MNISV3.Service.TourRec).GetTourDataV4("","DHCNurSpotTourPda","2025-08-25","2025-08-25","3","20665","8","2","","{""single"":""0"",""flag"":"""",""tab"":""DHCNurSpotTourPda/"",""scan"":""0"",""multiple"":""1"",""barcode"":"""",""open"":""0""}")
ClassMethod GetTourDataV4(episodeId, tab, fromDate, toDate, wardId, userId, locId, hospitalId, screenParts, extras) As %String
{
    n (episodeId, tab,fromDate, toDate, wardId, userId, locId, hospitalId, screenParts,extras,%session)
    s $zt="errGetTourDataV4"
    s ^GRS("GetTourDataV4")=$lb(episodeId,tab, fromDate, toDate, wardId, userId, locId, hospitalId, screenParts,extras)
    s Msg="成功",msgcode="999999",Status="0" //定义初始值
    s json=##class(%ArrayOfDataTypes).%New()
    //顶部tabs
    s tabs=..GetTourTabs() 
    s TXXTypes=##class(%ListOfDataTypes).%New()
    //RapidAssembly 是快速创建对象，参数1：keys, 后面是可变参数
    s keys="name,ID,backgroundColor,color,flag" 
    s rw=""
    f
    {   //遍历TOUR类型 配置信息
        s rw=$o(^CF.NUR.MNISV3.ModelFormI("Type"," TOUR",rw))
        q:rw=""
        s modelForm=##class(CF.NUR.MNISV3.ModelForm).%OpenId(rw) 
        s modelObj=##class(Nur.Tools).RapidAssembly(keys,modelForm.FormName,rw,"#37D4CF","#FFFFFF",modelForm.FormCode)
        d TXXTypes.Insert(modelObj)  
    }
    
    s patInfoList=##class(%ListOfDataTypes).%New()
    i episodeId'="" {//单患者
        s patinfo=##class(%ArrayOfDataTypes).%New()
        //基本患者信息
        s patinfo=##class(Nur.MNISV3.Service.Patient).GetBasicInfo(patinfo,episodeId)
        s tourData=..GetTourDataObj(episodeId,tab,fromDate,toDate)
        d patinfo.SetAt($g(tourData),"tourData")
        d patinfo.SetAt($g(tab),"type")
        d patInfoList.Insert(patinfo)
    }else {
        i tab="DHCNurSpotTourPda" { 
            s patinfo=##class(%ArrayOfDataTypes).%New()
            s tourData=..GetTourDataObj(episodeId,tab,fromDate,toDate)
            d patinfo.SetAt($g(tourData),"tourData")
            d patinfo.SetAt("hide","type") //地点巡视 不显示患者标题
            d patInfoList.Insert(patinfo)
        }else {
            //调用纯净版患者列表，
            s patListObj=##class(%ResultSet).%New("Nur.MNISV3.Service.Patient:GetPatList")
            d patListObj.Execute(wardId,userId,"Ward",locId)
            while(patListObj.Next()){
                s patinfo=##class(Nur.MNISV3.Common.Utils).ResultSet(patListObj)
                s episodeId=patListObj.GetDataByName("episodeId")
                s tourData=..GetTourDataObj(episodeId,tab,fromDate,toDate)
                d patinfo.SetAt($g(tourData),"tourData")
                d patinfo.SetAt($g(tab),"type")
                //基本患者信息
                s patinfo=##class(Nur.MNISV3.Service.Patient).GetBasicInfo(patinfo,episodeId)
                d patInfoList.Insert(patinfo)
            }
        }
    }
    d json.SetAt($g(Msg),"msg")
    d json.SetAt($g(Status),"status")
    d json.SetAt($g(tabs),"tabs")
    d json.SetAt($g(TXXTypes),"TXXTypes")
    d json.SetAt($g(patInfoList),"patients")
    d json.SetAt($g(nearDate),"nearDate")
    d json.SetAt($g(nearTime),"nearTime")
    q ##class(Nur.MNISV3.Common.JSON).Encode(json)
errGetTourDataV4
    s Msg=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJson(Msg,"100021","-1")
}

/// 巡视扫码--统一处理
/// 注意: 调试json可以传""---方便调试参数尽量是字符串
/// w ##class(Nur.MNISV3.Service.TourRec).GetScanTourInfo("PAT","scan","0000000689","[{""barcode"":""0000000689"",""entity"":""patient"",""result"":""1217"",""scan"":""1""}]","3","20665","8","23","2","{""single"":""0"",""flag"":"""",""tab"":""/"",""scan"":""0"",""multiple"":""1"",""barcode"":"""",""open"":""0""}")
/// w ##class(Nur.MNISV3.Service.TourRec).GetScanTourInfo("INF","scan","669||76||822","[{""barcode"":""669||76||822"",""entity"":""order"",""result"":"""",""scan"":""1""}]","3","20665","8","23","2","{""single"":""0"",""flag"":"""",""tab"":""/"",""scan"":""0"",""multiple"":""1"",""barcode"":"""",""open"":""0""}")
ClassMethod GetScanTourInfo(barcodeFlag, motion, barcode, entities, wardId, userId, locId, groupId, hospitalId, extras)
{
    n (barcodeFlag,motion, barcode, entities, wardId, userId, locId, groupId, hospitalId, extras)
    s $zt="errGetScanTourInfo"
    s ^GRS("GetScanTourInfo",barcode_"-")=$lb(barcodeFlag,motion, barcode, entities, wardId, userId, locId, groupId, hospitalId, extras)
    s Msg="成功",msgcode="999999",Status="0" //定义初始值
    s json=##class(%ArrayOfDataTypes).%New()
    s panels=##class(%ListOfDataTypes).%New()
    // 分级巡视
    i barcodeFlag="PAT" {
        s ModelCode="DHCNurGradeTourPda"
        s buttons=..GetButtonsByModelCode(ModelCode)
        //添加一个 患者信息from
        s modelInfo=##class(CF.NUR.MNISV3.ModelForm).GetModelInfoByModeCode("CommPatInfo!"_ModelCode,hospitalId)
        s modelList=modelInfo.GetAt("formList")   
        s modelInfoObj= ##class(Nur.MNISV3.Common.Utils).CreateModelInfo("1","分级巡视",buttons,modelList)
        d panels.Insert(modelInfoObj)
    }
    //输液巡视
    i barcodeFlag="INF" {
        s ModelCode="DHCNurInfusionTourPda"
        s buttons=..GetButtonsByModelCode(ModelCode)
        //添加一个 患者信息from
        s modelInfo=##class(CF.NUR.MNISV3.ModelForm).GetModelInfoByModeCode("CommOrderInfo!"_ModelCode,hospitalId)
        s modelList=modelInfo.GetAt("formList") 
        s modelInfoObj= ##class(Nur.MNISV3.Common.Utils).CreateModelInfo("2","输液巡视",buttons,modelList)
        d panels.Insert(modelInfoObj)
        // 获取entities中扫瓶贴
        s barCode2=##class(Nur.MNISV3.Common.Utils).GetBarcodeByEntities(entities,"order")
        s oeoreId=$p(barCode2,"^")
        s orders=##class(Nur.MNISV3.Service.Order).GetOrderInfoByBarCode(oeoreId)
        d json.SetAt($g(orders),"orders")
    }
    //地点巡视
    i barcodeFlag="SPOT" {
        s ModelCode="DHCNurSpotTourPda"
        s buttons=..GetButtonsByModelCode(ModelCode)
        s modelInfo=##class(CF.NUR.MNISV3.ModelForm).GetModelInfoByModeCode(ModelCode,hospitalId)
        s modelList=modelInfo.GetAt("formList")   
        s modelInfoObj= ##class(Nur.MNISV3.Common.Utils).CreateModelInfo("3","地点巡视",buttons,modelList)
        d panels.Insert(modelInfoObj)
    }
    // 输血巡视--"BLOODPRODUCT" 血制品  "BLOODBAG" 血袋
    i barcodeFlag="BLOOD" {
        s barCode2=##class(Nur.MNISV3.Common.Utils).GetBarcodeByEntities(entities,"blood","all")
        w barCode2,!
        i ($p(barCode2,"^",2)'="")&&($l($p(barCode2,"^",1))'=$l($p(barCode2,"^",2))){
            s barcodeFlag="BLOOD" //扫了两个码 长度不一样 
            s bloodInfoObj=##class(Nur.MNISV3.Service.Blood).GetBloodInfo($p(barCode2,"^",1),$p(barCode2,"^",2))
            s bloodInfo=bloodInfoObj.GetAt("bloodInfo")
            s modelList=##class(CF.NUR.MNISV3.ModelForm).GetModelInfoSingleWithObjectToList("BLOODINFO",hospitalId,bloodInfo)
            s ModelCode="DHCNurBloodTourPda"
            s buttons=..GetButtonsByModelCode(ModelCode)
            s modelInfo=##class(CF.NUR.MNISV3.ModelForm).GetModelInfoSingleByModelCode(ModelCode,hospitalId)
            d modelList.Insert(modelInfo)  
            s modelInfoObj= ##class(Nur.MNISV3.Common.Utils).CreateModelInfo("4","输血巡视",buttons,modelList)
            d panels.Insert(modelInfoObj)  
 
        }else {
            s toast2="请求再扫血制品或血袋码!" 
        }
    }
    d json.SetAt($g(Msg),"msg")
    d json.SetAt($g(Status),"status")
    d json.SetAt($g(barcodeFlag),"barcodeFlag")
    d json.SetAt($g(panels),"panels")
    d json.SetAt($g(toast2),"toast2")
    w ##class(Nur.MNISV3.Common.JSON).Encode(json),! //测试
    q json 
errGetScanTourInfo
    s ^GRS("errGetScanTourInfo")=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJsonObj($ze,"","-1")
}

/// 巡视保存--统一处理
/// 注意: 调试json可以传""---方便调试参数尽量是字符串
/// w ##class(Nur.MNISV3.Service.TourRec).SaveTour("save","DHCNurGradeTourPda","[{""barcode"":""0000000689"",""entity"":""patient"",""manual"":"""",""result"":""1217"",""scan"":""1""}]","3","20665","8","23","2","{""single"":""0"",""flag"":""1"",""tab"":""/"",""scan"":""0"",""multiple"":""1"",""barcode"":"""",""open"":""1""}","{""8||3"":""否"",""8||2"":""11:19"",""8||1"":""2025-08-22"",""8||7"":""通畅"",""8||6"":""俯卧位"",""8||5"":""意识模糊"",""8||4"":""请假""}","","")
/// w ##class(Nur.MNISV3.Service.TourRec).SaveTour("save","DHCNurInfusionTourPda","[{""barcode"":""1174||1169||128"",""entity"":""order"",""manual"":"""",""result"":"""",""scan"":""1""}]","3","20665","8","23","2","{""single"":""0"",""flag"":""1"",""tab"":""/"",""scan"":""0"",""multiple"":""1"",""barcode"":"""",""open"":""1""}","{""9||4"":""正常"",""9||3"":""穿刺"",""9||2"":""11:19"",""9||1"":""2025-08-22"",""9||6"":""888"",""9||5"":""重新穿刺""}","","")
/// w ##class(Nur.MNISV3.Service.TourRec).SaveTour("save","DHCNurSpotTourPda","[{""barcode"":""0000000689"",""entity"":""patient"",""manual"":"""",""result"":""1217"",""scan"":""1""},{""barcode"":""669||76||822"",""entity"":""order"",""manual"":"""",""result"":"""",""scan"":""1""},{""barcode"":""669||76||822"",""entity"":""order"",""manual"":"""",""result"":"""",""scan"":""1""},{""barcode"":""0000000689"",""entity"":""patient"",""manual"":"""",""result"":""1217"",""scan"":""1""}]","3","20665","8","23","2","{""single"":""0"",""flag"":""1"",""tab"":""/"",""scan"":""0"",""multiple"":""1"",""barcode"":"""",""open"":""1""}","{""10||1"":""2025-08-25"",""10||2"":""15:24"",""10||3"":""走廊"",""10||4"":""uuu""}","","")
ClassMethod SaveTour(motion, button, entities, wardId, userId, locId, groupId, hospitalId, extras, form, element, callback)
{
    n (motion, button, entities, wardId, userId, locId, groupId, hospitalId, extras,form,element,callback)
    s $zt="errSaveTour"
    s ^GRS("SaveTour",userId_"-"_button)=$lb(motion, button, entities, wardId, userId, locId, groupId, hospitalId, extras,form,element,callback)
    s Msg="成功",msgcode="999999",Status="0" //定义初始值
    s json=##class(%ArrayOfDataTypes).%New()
    s panels=##class(%ListOfDataTypes).%New()
    // 获取entities中就诊号
    s barCode1=##class(Nur.MNISV3.Common.Utils).GetBarcodeByEntities(entities,"patient")
    s episodeId=$p(barCode1,"^",2)
    // 获取entities中扫瓶贴
    s barCode2=##class(Nur.MNISV3.Common.Utils).GetBarcodeByEntities(entities,"order")
    s oeoreId=$p(barCode2,"^")
    i oeoreId'="" s episodeId=+^OEORD(+oeoreId)
    w $g(episodeId),"-",oeoreId,!
    ts
    s tourType=""
    // 分级巡视 
    i button="DHCNurGradeTourPda" {
        s tourType="Grade" 
        s parrStr=##class(CF.NUR.MNISV3.ModelItem).GetParrStrByForm(form)
        //扫码执行增加等级巡视插入
        s parr="DHCNurTourDate|"_+$h_"^DHCNurTourTime|"_$p($h,",",2)_"^DHCNurTourAdmDR|"_$g(episodeId)_"^DHCNurTourCtlocDR|"_locId_"^DHCNurTourPatBed|^DHCNurTourCareDR|^DHCNurTourCareDesc|^DHCNurTourUser|"_userId_"^DHCNurTourType|Grade^"
        i $g(episodeId)'="" s detailId=##class(Nur.MNISV3.GradeTourRec).Save(parr_parrStr,"",userId,form)
    } 
    // 输液巡视 
    i button="DHCNurInfusionTourPda" {
        s tourType="Infusion" 
        s parrStr=##class(CF.NUR.MNISV3.ModelItem).GetParrStrByForm(form)
        //扫码执行输液巡视插入
        s parr="DHCNurTourDate|"_+$h_"^DHCNurTourTime|"_$p($h,",",2)_"^DHCNurTourAdmDR|"_$g(episodeId)_"^DHCNurTourCtlocDR|"_locId_"^DHCNurTourPatBed|^DHCNurTourCareDR|^DHCNurTourCareDesc|^DHCNurTourUser|"_userId_"^DHCNurTourType|Infusion^"
        s parr=parr_"DHCNurTourInspectDR|"_$g(oeoreId)_"^"_parrStr //拼接
        s parr=$replace(parr,"||","-")
        i $g(oeoreId)'="" s detailId=##class(Nur.MNISV3.InfusionTourRec).Save(parr,"",userId,form)
    }
    // 地点巡视 
    i button="DHCNurSpotTourPda" {
        // 获取entities中地点码
        s barCode3=##class(Nur.MNISV3.Common.Utils).GetBarcodeByEntities(entities,"spot")
        s tourType="Spot" 
        s parrStr=##class(CF.NUR.MNISV3.ModelItem).GetParrStrByForm(form)
        //扫码执行增加等级巡视插入
        s parr="DHCNurTourDate|"_+$h_"^DHCNurTourTime|"_$p($h,",",2)_"^DHCNurTourCtlocDR|"_locId_"^DHCNurTourUser|"_userId_"^DHCNurTourType|Spot^DHCNurTourBarcodeType|"_$g(barCode3)_"^"
        s detailId=##class(Nur.MNISV3.SpotTourRec).Save(parr_parrStr,"",userId,form)
    } 
    // 输血巡视 
    i button="DHCNurBloodTourPda" {
        s barCode2=##class(Nur.MNISV3.Common.Utils).GetBarcodeByEntities(entities,"blood","all")
        w barCode2,!
        i ($p(barCode2,"^",2)'="")&&($l($p(barCode2,"^",1))'=$l($p(barCode2,"^",2))){
            s bloodInfoObj=##class(Nur.MNISV3.Service.Blood).GetBloodInfo($p(barCode2,"^",1),$p(barCode2,"^",2))
            s bloodInfo=bloodInfoObj.GetAt("bloodInfo")
            s episodeId=bloodInfo.GetAt("episodeId")
            s BloodBagNo=bloodInfo.GetAt("bloodbagId")
            s BloodProductNo=bloodInfo.GetAt("bloodProductId") 
            s BloodProducDesc=bloodInfo.GetAt("productDesc") _" "_bloodInfo.GetAt("bloodGroup") 
        }
        s tourType="Blood" 
        s parrStr=##class(CF.NUR.MNISV3.ModelItem).GetParrStrByForm(form)
        //扫码执行增加等级巡视插入
        s parr="DHCNurTourDate|"_+$h_"^DHCNurTourTime|"_$p($h,",",2)_"^DHCNurTourAdmDR|"_$g(episodeId)_"^DHCNurTourCtlocDR|"_locId_"^DHCNurTourUser|"_userId_"^DHCNurTourType|Blood^BloodBagNo|"_$g(BloodBagNo)_"^BloodProductNo|"_$g(BloodProductNo)_"^BloodProducDesc|"_$g(BloodProducDesc)_"^RecPref|"_$g(RecPref)_"^"
        s detailId=##class(Nur.MNISV3.BloodTourRec).Save(parr_parrStr,"",userId,form)
    } 
    w "detailId="_$g(detailId),!
    i $g(detailId)["err" tro  q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJsonObj(detailId,"","-1")
    //汇总巡视表保存
    i $g(detailId)'="" {
        s tRet=##class(Nur.MNISV3.SumTourRec).Save(parr,detailId,tourType,userId)
        i tRet["err"  tro  q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJsonObj(tRet,"","-1")
    }
    tc
    //输液巡视 同步平台
    i (tourType="Infusion") {
        ;d ##class(web.DHCMGNurComm).setmoudtmp(parr,.tmp)
        d ##class(Nur.MNISV3.InfusionTourRec).setmoudtmp(parr,.tmp)
        s oeoreId=$g(tmp("DHCNurTourInspectDR"))
        s locId=$g(tmp("DHCNurTourCtlocDR"))
        job ##class(Nur.MNIS.Service.EnsInterface).UpdateSystemStatus(oeoreId,"OrderExecute","tour",userId,locId,"","")
    }
    d json.SetAt($g(panels),"panels")
    d json.SetAt($g(Msg),"msg")
    d json.SetAt($g(Status),"status")
    d json.SetAt("巡视保存成功!","msg") 
    //行为控制-可以是多个"," 例如1: "open" 打开面板 "close" 关闭面板 "search" 刷新请求列表-->空即可d json.SetAt("","request")
    //例如2: behavior="request" 再调用"ExecOrSeeOrderV4"-->需要d json.SetAt("ExecOrSeeOrderV4","request")
    d json.SetAt("close,search","behavior") 
    //d json.SetAt("","request")
    w ##class(Nur.MNISV3.Common.JSON).Encode(json),! //测试
    q json 
errSaveTour
    s ^GRS("errSaveTour")=$ze
    q ##class(Nur.MNISV3.Common.Utils).ReturnMsgJsonObj($ze,"","-1")
}

/// 通过模板代码获取按钮列表
/// w ##class(Nur.JSON).Encode(##class(Nur.MNISV3.Service.TourRec).GetButtonsByModelCode("DHCNurGradeTourPda"))
ClassMethod GetButtonsByModelCode(ModelCode, behavior = "request", request = "")
{
    n (ModelCode,behavior,request)
    s buttons=##class(%ListOfDataTypes).%New() 
    //剩余 CallbackBean callback;String motion; String autoClickTimeout; String autoHideOnClick;
    s keys="id,text,behavior,request,backgroundColor,color,disabled" //'确定'按钮要唯一Id 会传参给后台button
    // "request" 是请求
    d buttons.Insert(##class(Nur.Tools).RapidAssembly(keys,"","取消","cancel","","#dbecff"))
    d buttons.Insert(##class(Nur.Tools).RapidAssembly(keys,ModelCode,"确定",behavior,request,"#067FFA"))
    q buttons
}

/// 获取顶部tab页签
/// w ##class(Nur.JSON).Encode(##class(Nur.MNISV3.Service.TourRec).GetTourTabs())
ClassMethod GetTourTabs()
{
    n 
    s tabs=##class(%ListOfDataTypes).%New()
    s keys="id,selected,title" //RapidAssembly 是快速创建对象，参数1：keys, 后面是可变参数
    s keyTab="flag,id,selected,title,children" 
    s rw=""
    f
    {   //遍历TOUR类型
        s rw=$o(^CF.NUR.MNISV3.ModelFormI("Type"," TOUR",rw))
        q:rw=""
        s modelForm=##class(CF.NUR.MNISV3.ModelForm).%OpenId(rw) 
        s children=##class(%ListOfDataTypes).%New()
        s FormSub=modelForm.FormSub
        i FormSub'="" { // 子类型---children
            f i=1:1:$l(FormSub,"!") {
               s name=$p(FormSub,"!",i)
               continue:name=""
               d children.Insert(##class(Nur.Tools).RapidAssembly(keys,i,"",name))
            }
          
        }
        s modelObj=##class(Nur.Tools).RapidAssembly(keyTab,modelForm.FormCode,rw,"",modelForm.FormName,children)
        d tabs.Insert(modelObj)  
    }
    q tabs
}

/// 获取巡视数据 通过日期和就诊
/// w ##class(Nur.JSON).Encode(##class(Nur.MNISV3.Service.TourRec).GetTourDataObj("1217","DHCNurInfusionTourPda","2025-08-25","2025-08-25"))
/// w ##class(Nur.JSON).Encode(##class(Nur.MNISV3.Service.TourRec).GetTourDataObj("1217","DHCNurGradeTourPda","2025-08-25","2025-08-25"))
/// w ##class(Nur.JSON).Encode(##class(Nur.MNISV3.Service.TourRec).GetTourDataObj("1217","DHCNurSpotTourPda","2025-08-25","2025-08-25"))
ClassMethod GetTourDataObj(episodeId, tab, fromDate, toDate)
{
    n (episodeId,tab,fromDate,toDate)
    s $zt="errGetTourDataObj"
    s ^GRS("GetTourDataObj")=$lb(episodeId,tab,fromDate,toDate)
    s tourDatas=##class(%ListOfDataTypes).%New()
    s tourType="Grade" 
    i tab="DHCNurGradeTourPda" s tourType="Grade" // 分级巡视 
    i tab="DHCNurInfusionTourPda" s tourType="Infusion"  // 输液巡视  
    i tab="DHCNurSpotTourPda" s tourType="Spot"  // 地点巡视  
    i tab="DHCNurBloodTourPda" s tourType="Blood"
    s startDate=##class(websys.Conversions).DateHtmlToLogical(fromDate)
    s endDate=##class(websys.Conversions).DateHtmlToLogical(toDate)

    f date=startDate:1:endDate {
        s rw=""
        f { 
            s rw=$o(^Nur.MNISV3.SumTourRecI("TourDate",date,rw)) 
            q:(rw="")
            s data=^Nur.MNISV3.SumTourRecD(rw)
            s adm=$lg(data,4)
            s type=$lg(data,7)
            //w type,"-",tourType,!
            continue:tourType'=type
            continue:(episodeId'="")&&(adm'="")&&(adm'=episodeId)
            s DetailDR=$lg(data,8)
            s info=##class(%ArrayOfDataTypes).%New()
            s fields=##class(%ListOfDataTypes).%New()
            s keys="id,name,type,value"
            i tourType="Grade" {
                s name="分级巡视"
                s obj=##class(Nur.MNISV3.GradeTourRec).%OpenId(DetailDR)
                d fields.Insert(##class(Nur.Tools).RapidAssembly(keys,"","是否离房","R",obj.DHCNurTourIfOut))
                d fields.Insert(##class(Nur.Tools).RapidAssembly(keys,"","总体状况","R",obj.DHCNurTourSTAT))
                s careLevel= ##class(Nur.NIS.Service.Base.Patient).GetCareLevel(obj.DHCNurTourAdmDR)
                i obj.DHCNurTourAdmDR=1217 s careLevel="一级护理"
                d info.SetAt($g(careLevel),"careLevel")
            } 
            i tourType="Infusion" {
                s name="输液巡视"
                s obj=##class(Nur.MNISV3.InfusionTourRec).%OpenId(DetailDR)
                s DHCNurTourInspectDR=obj.DHCNurTourInspectDR
                s orders=##class(Nur.MNISV3.Service.Order).GetOrderInfoByBarCode(DHCNurTourInspectDR)
                d info.SetAt($g(orders),"orders")
                d info.SetAt($g(careLevel),"careLevel") 
                d fields.Insert(##class(Nur.Tools).RapidAssembly(keys,"","巡视操作","R",obj.DHCNurTourInspectHandle))
                d fields.Insert(##class(Nur.Tools).RapidAssembly(keys,"","输液情况","R",obj.DHCNurTourInspectSTAT))
            } 
            i tourType="Spot" {
                s name="地点巡视"
                s obj=##class(Nur.MNISV3.SpotTourRec).%OpenId(DetailDR)
                s spot=##class(%ArrayOfDataTypes).%New()
                d spot.SetAt(obj.DHCNurTourSpot,"name") //添加spot对象
                d spot.SetAt(obj.DHCNurTourBarcodeType,"barCode")
                d info.SetAt($g(spot),"spot")
                d fields.Insert(##class(Nur.Tools).RapidAssembly(keys,"","巡视地点","R",obj.DHCNurTourSpot))
                d fields.Insert(##class(Nur.Tools).RapidAssembly(keys,"","其他","E",obj.Item4))
            } 
           i tourType="Blood" {
                s name="输血巡视"
                s obj=##class(Nur.MNISV3.BloodTourRec).%OpenId(DetailDR)
                s blood=##class(%ArrayOfDataTypes).%New()
                d blood.SetAt(obj.BloodProducDesc,"productDesc") //添加blood对象
                d blood.SetAt(obj.BloodBagNo,"BloodBagNo")
                d blood.SetAt(obj.BloodProductNo,"BloodProductNo")
                d info.SetAt($g(blood),"blood")
                d fields.Insert(##class(Nur.Tools).RapidAssembly(keys,"","巡视操作","R",obj.Item3))
                d fields.Insert(##class(Nur.Tools).RapidAssembly(keys,"","备注","E",obj.Item4))
            } 
            //公共的字段
            s user=$P($G(^SSU("SSUSR",obj.DHCNurTourUser)),"^",2)
            d info.SetAt($zd(obj.DHCNurTourDate,3),"date")
            d info.SetAt($zt(obj.DHCNurTourTime),"time")
            d info.SetAt($g(tab),"type")
            d info.SetAt($g(name),"name")
            d info.SetAt($g(user),"user") 
            s form=##class(%ArrayOfDataTypes).%New()
            d form.SetAt(fields,"fields")
            d info.SetAt($g(form),"form") 
            d tourDatas.Insert(info)
        }
    }
    q tourDatas
errGetTourDataObj
  w $ze,!
  q ##class(%ListOfDataTypes).%New()
}

}
